<!--
 * @Author: xiaodong 565071984@qq.com
 * @Date: 2022-05-08 20:56:20
 * @LastEditors: xiaodong 565071984@qq.com
 * @LastEditTime: 2022-05-08 22:12:52
 * @FilePath: /小票/src/views/orderManagement/roleManagement/components/UserManagementEdit.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogFormVisible"
    width="600px"
    @close="close"
  >
    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
      <el-form-item label="订单号">
        <span class="detail-value">{{ detail.order_no }}</span>
      </el-form-item>
      <el-form-item label="创建日期">
        <span class="detail-value">{{ detail.create_time }}</span>
      </el-form-item>
      <el-form-item label="订单类型">
        <span class="detail-value">
          {{ detail.order_type == 1 ? '新购' : '续费' }}
        </span>
      </el-form-item>
      <el-form-item label="购买时长">
        <span class="detail-value">
          {{ detail.order_time }}
        </span>
      </el-form-item>
      <el-form-item label="账号类型">
        <span class="detail-value">
          {{ detail.account_type == 1 ? '租户' : '设备' }}
        </span>
      </el-form-item>
      <el-form-item label="收费模式">
        <span class="detail-value">
          {{ detail.buy_type == 1 ? '按个' : '按套餐' }}
        </span>
      </el-form-item>
      <el-form-item label="购买此号">
        <span class="detail-value">{{ detail.buy_acount }}</span>
      </el-form-item>
      <el-form-item label="代理商账号">
        <span class="detail-value">{{ detail.agent_name }}</span>
      </el-form-item>
      <el-form-item label="操作人账号">
        <span class="detail-value">{{ detail.username }}</span>
      </el-form-item>
      <el-form-item label="订单备注">
        <span class="detail-value">{{ detail.order_mark }}</span>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <!-- <el-button @click="close">取 消</el-button> -->
      <el-button type="primary" @click="save">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { doEdit } from '@/api/roleManagement'

export default {
  name: 'RoleManagementEdit',
  data() {
    return {
      form: {
        id: '',
      },
      detail: {},
      rules: {
        permission: [
          { required: true, trigger: 'blur', message: '请输入权限码' },
        ],
      },
      title: '',
      dialogFormVisible: false,
    }
  },
  created() {},
  methods: {
    showEdit(row) {
      if (!row) {
        this.title = '添加'
      } else {
        this.title = '订单详情'
        this.form = Object.assign({}, row)
        this.detail = Object.assign({}, row)
      }

      console.log(row)
      this.dialogFormVisible = true
    },
    close() {
      this.$refs['form'].resetFields()
      this.form = this.$options.data().form
      this.dialogFormVisible = false
    },
    save() {
      this.$refs['form'].validate(async (valid) => {
        if (valid) {
          const { msg } = await doEdit(this.form)
          this.$baseMessage(msg, 'success')
          this.$emit('fetch-data')
          this.close()
        } else {
          return false
        }
      })
    },
  },
}
</script>
